import { createSlice } from "@reduxjs/toolkit"


const kind = createSlice({
    name: "kind",
    initialState: {
        proList: [
            {
                "proid": "pro_e374dae5-22d7-40d8-ade2-5aa6449624c3",
                "proname": "Apple iPhone 11 (A2223) 128GB 黑色 移动联通电信4G手机 双卡双待",
                "originprice": 4999,
                "sales": 4070000,
                "stock": 50000,
                "img1": "https://img12.360buyimg.com/n1/s450x450_jfs/t1/59022/28/10293/141808/5d78088fEf6e7862d/68836f52ffaaad96.jpg"
            }
        ]
    },
    reducers: {
        addPro(state, action) {
            state.proList.push(action.payload);
        },
        removePro(state, action) {
            state.proList = state.proList.filter(item => item.proid === action.payload);
        }
    }
});

// 对外暴露：actions
export const { addPro, removePro } = kind.actions;

// 对外暴露reducer
export default kind.reducer;

// {
//     "link": "2",
//     "alt": "2",
//     "img": "https://gimg3.baidu.com/search/src=http%3A%2F%2Fpics0.baidu.com%2Ffeed%2F78310a55b319ebc4c061c377e7b56ff01f171666.jpeg%40f_auto%3Ftoken%3Db32023b11c69bd3889c56d2e2142c271&refer=http%3A%2F%2Fwww.baidu.com&app=2021&size=f360,240&n=0&g=0n&q=75&fmt=auto?sec=1692118800&t=301d10ca47f0f885909f32b29f5f4bbc",
//     "bannerid": "banner_351aa6ff-7017-4dd5-90a2-6eb8cf9e11b5",
//     "flag": true
// },